<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jstl/core"
                xmlns:sf="http://www.springframework.org/tags/faces"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:spring="http://www.springframework.org/tags"
                template="../../../layout/Template.xhtml">

    <ui:define name="menu">
        <ui:include src="${user.menu}"/>
    </ui:define>

    <ui:define name="title">
        <h:outputText value="#{resourceBundle.readLessonWelcome}"/>
    </ui:define>

    <ui:define name="content">
        <h:form id="readLessonForm">
            <rich:panel id="readLessonPanel"
                        header="#{resourceBundle.readLessonWelcome}">

                <h:panelGrid id="readLessonGrid" columns="2">
                    <h:outputText value="#{resourceBundle.readLessonTextUnitName} : "/>
                    <h:outputText value="#{currentLesson.unitName}"/>

                    <h:outputText value="#{resourceBundle.readLessonTextSubject} : "/>
                    <h:outputText value="#{currentLesson.subject}"/>

                    <h:outputText value="#{resourceBundle.readLessonTextContain} : "/>

                    <h:panelGroup>
                        <rich:modalPanel id="panelHTML" width="800" height="600">
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="#{currentLesson.linkSupport} HTML"></h:outputText>
                                </h:panelGroup>
                            </f:facet>
                            <f:facet name="controls">
                                <h:panelGroup>
                                    <h:graphicImage value="/img/close.png"
                                                    styleClass="hidelink"
                                                    id="hidelinkHTML"/>
                                    <rich:componentControl for="panelHTML"
                                                           attachTo="hidelinkHTML"
                                                           operation="hide"
                                                           event="onclick"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value="#{currentLesson.contain}" escape="false"/>
                        </rich:modalPanel>

                        <h:outputLink value="#" id="linkHTML">
                            <h:outputText value="#{currentLesson.linkSupport} HTML"/>
                            <rich:componentControl for="panelHTML"
                                                   attachTo="linkHTML"
                                                   operation="show"
                                                   event="onclick"/>
                        </h:outputLink>

                    </h:panelGroup>
                    <h:outputText
                            value="#{resourceBundle.readLessonTextLinkSupport} : "/>
                    <h:panelGroup>
                        <rich:modalPanel id="panelPDF"
                                         width="800"
                                         height="600">
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="#{currentLesson.linkSupport} PDF"/>
                                </h:panelGroup>
                            </f:facet>
                            <f:facet name="controls">
                                <h:panelGroup>
                                    <h:graphicImage value="/img/close.png"
                                                    styleClass="hidelink"
                                                    id="hidelinkPDF"/>
                                    <rich:componentControl for="panelPDF"
                                                           attachTo="hidelinkPDF"
                                                           operation="hide"
                                                           event="onclick"/>
                                </h:panelGroup>
                            </f:facet>
                            <rich:panel>
                                <a4j:mediaOutput element="object"
                                                 mimeType="application/pdf"
                                                 type="application/pdf"
                                                 codetype="application/pdf"
                                                 createContent="#{mediaBean.paint}"
                                                 value="#{currentLesson.id}"
                                                 cacheable="false"
                                                 width="780" height="570">

                                    <!-- classid="clsid:CA8A9780-280D-11CF-A24D-444553540000" -->
                                    <!--
                                   <object class="pdf"
                                           classid="clsid:CA8A9780-280D-11CF-A24D-444553540000"
                                           data="#{mediaBean.generatepdf(currentLesson.id)}"
                                           codetype="application/pdf"
                                           type="text/html"
                                           width="100%"
                                           height="100%" onclick="#{rich:component('panelPDF')}.hide()"/>
                                    -->
                                    <f:param value="#{mediaBean.timeStamp}" name="time"/>
                                </a4j:mediaOutput>
                            </rich:panel>
                        </rich:modalPanel>

                        <h:outputLink value="#" id="linkPDF">
                            <h:outputText value="#{currentLesson.linkSupport} PDF"/>
                            <rich:componentControl for="panelPDF"
                                                   attachTo="linkPDF"
                                                   operation="show"
                                                   event="onclick"/>
                        </h:outputLink>

                        <h:commandLink id="dl"
                                       value="(#{resourceBundle.readLessonDownload})"
                                       action="download"
                                       rendered="false"
                                       type="submit"/>
                    </h:panelGroup>
                    <h:outputText value="#{resourceBundle.readLessonTextDate} : "/>
                    <h:outputText value="#{currentLesson.date}">
                        <f:convertDateTime pattern="dd/MM/yy" type="date"/>
                    </h:outputText>

                    <h:outputText value="#{resourceBundle.readLessonTextStartTime} : "/>
                    <h:outputText value="#{currentLesson.startTime}">
                        <f:convertDateTime pattern="HH:mm" type="time"/>
                    </h:outputText>

                    <h:outputText value="#{resourceBundle.readLessonTextEndTime} : "/>
                    <h:outputText value="#{currentLesson.endTime}">
                        <f:convertDateTime pattern="HH:mm" type="time"/>
                    </h:outputText>

                    <a4j:commandButton id="readLessonBackButton"
                                       value="#{bundle.backButton}"
                                       action="backToListLesson"/>
                </h:panelGrid>
            </rich:panel>
        </h:form>
    </ui:define>

</ui:composition>